/*
https://leetcode-cn.com/problems/check-if-all-the-integers-in-a-range-are-covered/solution/jian-cha-shi-fou-qu-yu-nei-suo-you-zheng-5hib/
 */
public class Solution1893 {
    public boolean isCovered(int[][] ranges, int left, int right) {
        int[] d=new int[55];
        for (int[] range : ranges) {
            d[range[0]]++;
            d[range[1]+1]--;
        }
        int c=0;
        for (int i=1;i<=right;i++){
            c=c+d[i];
            if (c==0 && i>=left){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1893().isCovered(new int[][]{{1,2},{3,4},{5,6}},2,5));
    }
}
